	
using System;
using System.Collections.Generic;
using System.Linq;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using CiA.Facebook.Authorization;

namespace CiA
{
	public partial class LoginViewController : UIViewController
	{
		
		private LoginNavigationController _loginNavigationController
		{ 
			get 
			{ 
				return (LoginNavigationController)this.ParentViewController;
			}
		}
		
		#region Constructors

		// The IntPtr and initWithCoder constructors are required for items that need 
		// to be able to be created from a xib rather than from managed code

		public LoginViewController (IntPtr handle) : base(handle)
		{
			Initialize ();
		}

		[Export("initWithCoder:")]
		public LoginViewController (NSCoder coder) : base(coder)
		{
			Initialize ();
		}

		public LoginViewController () : base("LoginViewController", null)
		{
			Initialize ();
		}

		void Initialize ()
		{
		}
		
		#endregion
		
		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();
			Console.WriteLine("login view controller loaded");
			
			this.Title = "Login";
			
			imgviewContiki.Image = UIImage.FromFile("images/logo.png");
			
			btnFacebookConnect.SetImage(UIImage.FromFile("images/LoginWithFacebookNormal.png"),UIControlState.Normal);
			btnFacebookConnect.SetImage(UIImage.FromFile("images/LoginWithFacebookPressed.png"),UIControlState.Highlighted);
			btnFacebookConnect.TouchUpInside += HandleBtnFacbeookTouchUpInside;
			
			btnContikiCommunity.TouchUpInside += HandleBtnContikiCommunityTouchUpInside;
		}

		void HandleBtnContikiCommunityTouchUpInside (object sender, EventArgs e)
		{
			ContikiCommunityViewController contikiCommunityViewController = new ContikiCommunityViewController();
			_loginNavigationController.PushViewController(contikiCommunityViewController,true);
		}

		void HandleBtnFacbeookTouchUpInside (object sender, EventArgs e)
		{
			FacebookAuthorizationViewController fbController = new FacebookAuthorizationViewController("138729236173859",new string[0],FbDisplayType.Touch);
			_loginNavigationController.PushViewController(fbController,true);
		}
	}
}

